import java.util.Random;

public class PokeBall {
    private String name="精灵球";
    private Pokemon pokemon;
    public boolean catchPokemon(Pokemon p){
        Random random = new Random();
        double result = random.nextDouble();
        if(result<0.6){
            System.out.println("成功捕捉了"+p.getName());
            this.pokemon = p;
            this.pokemon.setHealth(true);
            this.pokemon.setHP(100);
            this.pokemon.setOnRoom(false);
            return true;
        }else {
            System.out.println("很遗憾，捕捉失败");
            return false;
        }
    }

    public void addPokemon(Pokemon pokemon){
         this.pokemon=pokemon;
//        if(name=="小火龙"){
//            this.pokemon = new Xiaohuolong();
//        }
//        if(name=="杰尼龟"){
//            this.pokemon = new jienigui();
//        }
//        if(name=="皮卡丘"){
//            this.pokemon = new Pikaqiu();
//        }
    }
    public Pokemon getPokemon(){
        return this.pokemon;
    }
    @Override
    public String toString() {
        return "PokeBall{" +
                "'" + name + '\'' +
                "-宝可梦：" + pokemon +
                '}';
    }
}
